From 2ccd134cf168f5effdc1848fc57fcd629ba0e119 Mon Sep 17 00:00:00 2001 From: oliskoli Date: Fri, 5 Sep 2008 18:22:14 +0000 Subject: [PATCH] gbfile: Add support for reading UNICODE text files (using gbfgetstr). --- gbfile.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gbfile.c b/gbfile.c index 73f76e7cb..554c4b641 100644 --- a/gbfile.c +++ b/gbfile.c @@ -938,9 +938,17 @@ gbfunicode(gbfile *file) file->unicode_checked = 1; + c = gbfgetc(file); + if (c == EOF) return 0; + + if ((c != 0xFE) && (c != 0xFF)) { + gbfungetc(c, file); + return 0; + } + pos = gbftell(file); gbfrewind(file); - c = gbfgetc(file) | (gbfgetc(file) << 8); + c = c | (gbfgetc(file) << 8); if (c == 0xFEFF) file->big_endian = 0; else if (c == 0xFFFE) file->big_endian = 1; @@ -948,6 +956,7 @@ gbfunicode(gbfile *file) gbfseek(file, pos, SEEK_SET); return 0; } + file->unicode = 1; if (pos != 0) gbfseek(file, pos, SEEK_SET); } -- 2.30.2